import { defineStore } from 'pinia'
import { ref } from 'vue'

import { toast } from '@/utils/toast'
interface IGeoInfo {
  longitude: number
  latitude: number
  updateTime: string
}

// 初始化状态
const userGeo: IGeoInfo = {
  longitude: 0,
  latitude: 0,
  updateTime: ''
}

export const useGeoStore = defineStore(
  'geo',
  () => {
    const geoInfo = ref<IGeoInfo>({ ...userGeo })
    const setGeoInfo = (val: IGeoInfo) => {
      geoInfo.value = val
    }
    return {
      setGeoInfo,
      geoInfo
    }
  },
  {
    persist: true,
  },
)
